home *** CD-ROM | disk | FTP | other *** search
-
-
-
- RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++)))) RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
-
-
-
- NNNNaaaammmmeeee
- RWGOrderedVector(val) - Rogue Wave library class
-
- SSSSyyyynnnnooooppppssssiiiissss
- #include <rw/gordvec.h>
-
-
-
- declare(RWGVector,val)
- declare(RWGOrderedVector,val)
- implement(RWGVector,val)
- implement(RWGOrderedVector,val)
- RWGOrderedVector(val) v;// Ordered vector of objects of val val.
-
-
-
-
- DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
- Class RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((vvvvaaaallll)))) represents an ordered collection of objects
- of val vvvvaaaallll. Objects are ordered by the order of insertion and are
- accessible by index. Duplicates are allowed. RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((vvvvaaaallll)))) is
- implemented as a vector, using macros defined in the standard C++ header
- file <<<<ggggeeeennnneeeerrrriiiicccc....hhhh>>>>. Note that it is a vvvvaaaalllluuuueeee----bbbbaaaasssseeeedddd collection: items are
- copied in and out of the collection. The class vvvvaaaallll must have:
- a default constructor;
-
- well-defined copy semantics (vvvvaaaallll::::::::vvvvaaaallll((((ccccoooonnnnsssstttt vvvvaaaallll&&&&)))) or equiv.);
-
- well-defined assignment semantics (vvvvaaaallll::::::::ooooppppeeeerrrraaaattttoooorrrr====((((ccccoooonnnnsssstttt vvvvaaaallll&&&&)))) or
- equiv.);
-
- well-defined equality semantics (vvvvaaaallll::::::::ooooppppeeeerrrraaaattttoooorrrr========((((ccccoooonnnnsssstttt vvvvaaaallll&&&&)))) or
- equiv.).
-
- To use this class you must declare and implement its base class as well
- as the class itself. For example, here is how you declare and implement
- an ordered collection of doubles:.Ex
- declare(RWGVector,double) // Declare base class
-
-
-
- declare(RWGOrderedVector,double) // Declare ordered vector
- // In one and only one .cpp file you must put the following:
- implement(RWGVector,double) // Implement base class
- implement(RWGOrderedVector,double) // Implement ordered vector
-
-
- For each val of RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr you must include one (and only one) call
- to the macro iiiimmmmpppplllleeeemmmmeeeennnntttt somewhere in your code for both the
-
-
-
-
-
-
- PPPPaaaaggggeeee 1111
-
-
-
-
-
-
- RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++)))) RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
-
-
-
- RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr itself and for its base class RRRRWWWWGGGGVVVVeeeeccccttttoooorrrr.
-
- PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
- None
-
- EEEExxxxaaaammmmpppplllleeee
- Here's an example that uses an ordered vector of RRRRWWWWCCCCSSSSttttrrrriiiinnnnggggs.
-
- #include <rw/gordvec.h>
- #include <rw/cstring.h>
- #include <rw/rstream.h>
- declare(RWGVector,RWCString)
- declare(RWGOrderedVector,RWCString)
- implement(RWGVector,RWCString)
- implement(RWGOrderedVector,RWCString)
- main() {
- RWGOrderedVector(RWCString) vec;
- RWCString one("First");
- vec.insert(one);
- vec.insert("Second"); // Automatic val conversion occurs
- vec.insert("Last"); // Automatic val conversion occurs
- for(size_t i=0; i<vec.entries(); i++) cout << vec[i] << endl;
- return 0;
- }
-
-
- Program output:
-
- First
- Second
- Last
-
- PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
- RWGOrderedVector(val)(size_t capac=RWDEFAULT_CAPACITY);
-
-
- Construct an ordered vector of elements of val vvvvaaaallll. The initial capacity
- of the vector will be ccccaaaappppaaaacccc whose default value is RRRRWWWWDDDDEEEEFFFFAAAAUUUULLLLTTTT____CCCCAAAAPPPPAAAACCCCIIIITTTTYYYY.
- The capacity will be automatically increased as necessary should too many
- items be inserted, a relatively expensive process because each item must
- be copied into the new storage.
-
- PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
- val
- ooooppppeeeerrrraaaattttoooorrrr(((())))(size_t i) const;
- val&
- ooooppppeeeerrrraaaattttoooorrrr(((())))(size_t i);
-
-
- Return the iiiith value in the vector. The index iiii must be between 0 and
- one less than the number of items in the vector. No bounds checking is
- performed. The second variant can be used as an lvalue, the first
-
-
-
- PPPPaaaaggggeeee 2222
-
-
-
-
-
-
- RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++)))) RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
-
-
-
- cannot.
-
- val
- ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](size_t i) const;
- val&
- ooooppppeeeerrrraaaattttoooorrrr[[[[]]]](size_t i);
-
-
- Return the iiiith value in the vector. The index iiii must be between 0 and
- one less than the number of items in the vector. Bounds checking will be
- performed. The second variant can be used as an lvalue, the first
- cannot.
-
- void
- cccclllleeeeaaaarrrr();
-
-
- Remove all items from the collection.
-
- const val*
- ddddaaaattttaaaa() const;
-
-
- Returns a pointer to the raw data of self. Should be used with care.
-
- size_t
- eeeennnnttttrrrriiiieeeessss() const;
-
-
- Return the number of items currently in the collection.
-
- size_t
- iiiinnnnddddeeeexxxx(vvvvaaaallll item) const;
-
-
- Perform a linear search of the collection returning the index of the
- first item that iiiissssEEEEqqqquuuuaaaallll to the argument iiiitttteeeemmmm. If no item is found, then
- it returns RRRRWWWW____NNNNPPPPOOOOSSSS.
-
- void
- iiiinnnnsssseeeerrrrtttt(vvvvaaaallll item);
-
-
- Add the new value iiiitttteeeemmmm to the end of the collection.
-
- void
- iiiinnnnsssseeeerrrrttttAAAAtttt(size_t indx, vvvvaaaallll item);
-
-
- Add the new value iiiitttteeeemmmm to the collection at position iiiinnnnddddxxxx. The value of
- iiiinnnnddddxxxx must be between zero and the length of the collection. No bounds
- checking is performed. Old items from index iiiinnnnddddxxxx upwards will be shifted
-
-
-
- PPPPaaaaggggeeee 3333
-
-
-
-
-
-
- RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++)))) RRRRWWWWGGGGOOOOrrrrddddeeeerrrreeeeddddVVVVeeeeccccttttoooorrrr((((3333CCCC++++++++))))
-
-
-
- to higher indices.
-
- RWBoolean
- iiiissssEEEEmmmmppppttttyyyy() const;
-
-
- Returns TTTTRRRRUUUUEEEE if the collection has no entries. FFFFAAAALLLLSSSSEEEE otherwise.
-
- void
- ssssiiiizzzzeeee____tttt
- lllleeeennnnggggtttthhhh() const;
-
-
- Synonym for eeeennnnttttrrrriiiieeeessss(((()))).
-
- vvvvaaaallll
- ppppoooopppp();
-
-
- Removes and returns the last item in the vector.
-
- vvvvooooiiiidddd
- ppppuuuusssshhhh(val);
-
-
- Synonym for iiiinnnnsssseeeerrrrtttt(((()))).
-
- rrrreeeemmmmoooovvvveeeeAAAAtttt(size_t indx);
-
-
- Removes the item at position iiiinnnnddddxxxx from the collection. The value of iiiinnnnddddxxxx
- must be between zero and one less than the length of the collection. No
- bounds checking is performed. Old items from index iiiinnnnddddxxxx++++1111 will be
- shifted to lower indices. E.g...., the item at index iiiinnnnddddxxxx++++1111 will be moved
- to position iiiinnnnddddxxxx, etc.
-
- void
- rrrreeeessssiiiizzzzeeee(size_t newCapacity);
-
-
- Change the capacity of the collection to nnnneeeewwwwCCCCaaaappppaaaacccciiiittttyyyy, which must be at
- least as large as the present number of items in the collection. Note
- that the actual number of items in the collection does not change, just
- the capacity.
-
-
-
-
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 4444
-
-
-
-